<template>
  <div class="goods-item" v-if="list">
    <!-- <a :href="list.link"> -->
        <img :src="show" alt="" @load="imgload" @click="loaddetail">
    <!-- </a> -->
    <div>
      <p> {{list.title}}</p>
    <span class="goods-item-span1">{{list.price}}</span>
    <span class="goods-item-span2">{{list.cfav}}</span>
    </div>
  </div>
</template>

<script>
export default {
  name:"item",
  data(){
    return{

    }
  },
props:{
  list:{
    type:Object,
    default(){
      return {}
    }
  }
},
computed:{
  show(){
    return  this.list.image || this.list.show.img //注意this.list.image和this.list.show.img顺序因为当进到这里时
  }
},
methods:{

   imgload(){
     this.$bus.$emit('goodsimg')
   },
   loaddetail(){
     this.$router.push('/detail/'+this.list.iid)
   }
}
}
</script>

<style>
.goods-item{
  flex: 1;
  width: 47vh;
  position: relative;
  text-align: center;
}
.goods-item img{
  width: 47vw;
  border-radius: 5px;
  padding-bottom: 40px;
}
.goods-item p{
  padding-left: 9px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.goods-item div{
  font-size: 13px;
  position: absolute;
  overflow: hidden;
  bottom: 5px;
  left: 0%;
  right: 0;
}
.goods-item .goods-item-span1{
  font-size: 10zpx;
  color: rgb(238, 157, 170);

}
.goods-item .goods-item-span2{
  font-size: 10px;
  color: black;
}
 .goods-item-span2::before{
   content: '';
   position: absolute;
    left: -15px;
    top: -1px;
    width: 14px;
    height: 14px;
    background: url("../../../assets/img/common/collect.svg") 0 0/14px 14px;

 }
</style>